﻿@{
    ViewBag.Title = "原材料库盘点单据信息编辑";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script type="text/javascript">
    $(function () {
        initControl();
    });

    function initControl() {
        //var FDocuListID = $.request("FDocuListID");
        //if (!!FDocuListID) {
            
        //}
        var editData = eval('(' + $("#editObject").val() + ')');
        $("#form1").formSerialize(editData);
        if ($('#FDocuNO').val() != '') {
            $('#FDocuNOShow').val($('#FDocuNO').val());
        }
        initBindSelect("#form1");

        initFStoreNO($('#FDocuTypeNO').val());
        initFStoreSetNO($("#FStoreNO").val());
        $('#FDocuTypeNO').on("change", function () {
            initFStoreNO($('#FDocuTypeNO').val());
        });
        $('#FStoreNO').on("change", function () {
            initFStoreSetNO($("#FStoreNO").val());
        });

        lockInputById("#item");
        lockInputById("#detail1");
        lockInputById("#detail2");
        
        $('#FQuantity').prop("disabled", false);
        $('#FZS').prop("disabled", false);
        $('#FPrice').prop("disabled", false);
        $('#FDescription2').prop("disabled", false);
    }
    function initFStoreNO(FDocuTypeNO) {
        $("#FStoreNO").empty();
        $("#FStoreNO").bindSelect({
            url: "/WareHouse/MaterialStore/GetStoreHouseListJson",
            id: "FStoreNO",
            text: "FStoreNoAndName",
            param: { FDocuTypeNO: FDocuTypeNO },
            search: false
        });
    }
    function initFStoreSetNO(storeNO) {
        $("#FStoreSetNO").empty();
        $("#FStoreSetNO").bindSelect({
            url: "/WareHouse/MaterialStore/GetStoreHouseSetListJson",
            id: "FStoreSetNO",
            text: "FStoreSetNO",
            param: { storeNO: storeNO },
            search: false
        });
    }
    function btn_ok() {
        if (!$('#form1').formValid()) {

        } else {
            var param = $("#item").formSerialize();
            var detail = $(".detailForm").formSerialize();
            detail["FDescription"] = detail["FDescription2"];
            param["detail"] = JSON.stringify(detail);
            $.submitForm({
                url: "/WareHouse/MaterialStore/SubmitMaterialStoreInventoryForm?status=U",
                param: param,
                close: false,
                success: function (result) {
                    //setDataByJson('#item', result.data);
                    //if ($('#FDocuNO').val() != '') {
                    //    $('#FDocuNOShow').val($('#FDocuNO').val());
                    //}
                    //lockInputById("#item");
                    //$('#FDescription').prop("disabled", false);
                    //emptyDataById("#detail");
                    //initBindSelect("#detail");

                    var isdetail = $.request("isdetail");
                    if (!!isdetail && isdetail == '1') {
                        var father = $.currentSubSubWindow().frames["Detail"];
                        father.reloadPageData($("#item").formSerialize());
                    } else {
                        var father = $.currentSubSubWindow();
                        father.reloadPageData();
                    }                    
                }
            })
        }
    }
    function btn_cancel() {
        var isdetail = $.request("isdetail");
        if (!!isdetail && isdetail == '1') {
            var father = $.currentSubSubWindow().frames["Detail"];
            father.$.detailCloseTop();
        } else {
            var father = $.currentSubSubWindow();
            father.$.detailCloseTop();
        }
    }
</script>
<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div style="padding-top: 1px;margin-left:10px;margin-right:10px;">
        <input id="editObject" name="" type="hidden" value="@ViewBag.editObject">
        <form id="form1">
            <table id="item" class="form" style="margin:5px 0;">
                <tr>
                    <th class="formTitle" style="width:60px;">&nbsp;</th>
                    <td class="formValue" style="width:220px;">
                        &nbsp;
                    </td>
                    <th class="formTitle" style="width:60px;">&nbsp;</th>
                    <td class="formValue" style="width:220px;">
                        &nbsp;
                    </td>
                    <th class="formTitle" style="width:60px;">单据编号</th>
                    <td class="formValue">
                        <input id="FDocuNOShow" name="FDocuNOShow" type="text" class="form-control" disabled="disabled" value="" />
                        <input id="FDocuNO" name="FDocuNO" type="hidden" value="">
                    </td>
                </tr>
                <tbody style="border: 1px solid #ddd;">
                    <tr>
                        <th class="formTitle" style="width:60px;">发生方式</th>
                        <td class="formValue" style="width:220px;">
                            <select id="FDocuTypeNO" name="FDocuTypeNO" class="form-control required">
                                @foreach (var item in ViewBag.fdocutypenoList)
                            {
                                    <option value="@item.FTypeNO">@item.FTypeNO @item.FTypeName</option>
                            }
                            </select>
                        </td>
                        <th class="formTitle" style="width:60px;">单据日期</th>
                        <td class="formValue" style="width:220px;">
                            <input id="FCurDate" name="FCurDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" />
                        </td>
                        <th class="formTitle" style="width:60px;">凭证编号</th>
                        <td class="formValue">
                            <input id="FCredence" name="FCredence" type="text" class="form-control required" value="" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">来料单位</th>
                        <td class="formValue">
                            <select id="FHappenComNO" name="FHappenComNO" class="form-control required">
                            @foreach (var item in ViewBag.fhappencomList)
                            {
                                <option value="@item.UnitNO">@item.UnitNO @item.UnitShortName</option>
                            }
                            </select>
                        </td>
                        <th class="formTitle">摘要说明</th>
                        <td class="formValue">
                            <input id="FDescription" name="FDescription" type="text" class="form-control" />
                        </td>
                        <th class="formTitle">合同编号</th>
                        <td class="formValue">
                            <input id="FCertificateNo" name="FCertificateNo" type="text" class="form-control" value="" />
                        </td>
                    </tr>
                </tbody>
            </table>
            <table id="detail1" class="form detailForm" style="border:1px solid #ddd;">
                <tr>
                    <th class="formTitle" style="width:60px;">材料分类</th>
                    <td class="formValue" style="width:220px;">
                        <input id="FDocuListID" name="FDocuListID" type="hidden" value="">
                        <select id="MaterialNO" name="MaterialNO" class="form-control">
                            @foreach (var item in ViewBag.materialnoList)
                            {
                            <option value="@item.MaterialNO">@item.MaterialNO @item.MaterialName</option>
                            }
                        </select>
                    </td>
                    <th class="formTitle" style="width:60px;">材料牌号</th>
                    <td class="formValue" style="width:220px;">
                        <input id="MaterialCode" name="MaterialCode" type="text" class="form-control" value="" />
                    </td>
                    <th class="formTitle" style="width:60px;">&nbsp;</th>
                    <td class="formValue">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">材料规格</th>
                    <td class="formValue">
                        <input id="MaterialSizes" name="MaterialSizes" type="text" readonly="readonly" class="form-control " />
                    </td>
                    <th class="formTitle">标准编号</th>
                    <td class="formValue">
                        <input id="StandardNumber" name="StandardNumber" type="text" readonly="readonly" class="form-control" />
                    </td>
                    <th class="formTitle" style="width:100px;">特殊要求</th>
                    <td class="formValue">
                        <input id="MaterialDemand" name="MaterialDemand" type="text" readonly="readonly" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">仓库编号</th>
                    <td class="formValue">
                        <select id="FStoreNO" name="FStoreNO" class="form-control required">
                        </select>
                    </td>
                    <th class="formTitle">炉批号</th>
                    <td class="formValue">
                        <input id="FOvenNum" name="FOvenNum" type="text" class="form-control"  />
                    </td>
                    <th class="formTitle">&nbsp;</th>
                    <td class="formValue">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">仓库库位</th>
                    <td class="formValue">
                        <select id="FStoreSetNO" name="FStoreSetNO" class="form-control required"></select>
                    </td>
                    <th class="formTitle">捆包号</th>
                    <td class="formValue">
                        <input id="FBatchNo" name="FBatchNo" type="text" class="form-control"/>
                    </td>
                    <th class="formTitle">出厂日期</th>
                    <td class="formValue">
                        <input id="WagonNumber" name="WagonNumber" type="text" class="form-control input-wdatepicker" value="" onfocus="WdatePicker()" />
                    </td>
                </tr>
            </table>
            <table id="detail2" class="form detailForm" style="border: 1px solid #ddd; margin-top: 5px;">
                <tr>
                    <th class="formTitle" style="width:60px;">发交重量</th>
                    <td class="formValue" style="width:220px;">
                        <input id="FQuantity_KP" name="FQuantity_KP" type="text" class="form-control text-right required isNumber" style="width:120px;margin-left:0px;" /><label style="margin-left:12px">KG</label>
                    </td>
                    <th class="formTitle" style="width:60px;">实际重量</th>
                    <td class="formValue" style="width:220px;">
                        <input id="FQuantity" name="FQuantity" type="text" class="form-control text-right required isNumber" style="width:120px;margin-left:0px;" /><label style="margin-left:12px">KG</label>
                    </td>
                    <th class="formTitle" style="width:60px;">&nbsp;</th>
                    <td class="formValue">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">盘点张数</th>
                    <td class="formValue">
                        <input id="FZS_KP" name="FZS_KP" type="text" class="form-control text-right required isInteger" style="width:120px;margin-left:0px;" />
                    </td>
                    <th class="formTitle">实际张数</th>
                    <td class="formValue">
                        <input id="FZS" name="FZS" type="text" class="form-control text-right required isInteger" style="width:120px;margin-left:0px;" />
                    </td>
                    <th class="formTitle">包数数量</th>
                    <td class="formValue">
                        <input id="FConQuatity" name="FConQuatity" type="text" class="form-control text-right required digits" style="width:120px;margin-left:0px;" /><label style="margin-left:12px">件</label>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">制造单位</th>
                    <td class="formValue">
                        <select id="FProCompanyNO" name="FProCompanyNO" class="form-control">
                        @foreach (var item in ViewBag.fprocompanyList)
                        {
                            <option value="@item.UnitNO">@item.UnitNO @item.UnitShortName</option>
                        }
                        </select>
                    </td>
                    <th class="formTitle">材料单价</th>
                    <td class="formValue">
                        <input id="FPrice" name="FPrice" type="text" class="form-control text-right number" style="width:120px;margin-left:0px;" /><label style="margin-left:12px">元</label>
                    </td>
                    <th class="formTitle">材料金额</th>
                    <td class="formValue">
                        <input id="FMoney" name="FMoney" type="text" class="form-control text-right required isNumber" style="width:120px;margin-left:0px;" /><label style="margin-left:12px">元</label>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">备注说明</th>
                    <td class="formValue" colspan="5">
                        <input id="FDescription2" name="FDescription2" type="text" class="form-control" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div style="text-align:right;margin-left: 10px; margin-right: 10px;padding:5px 40px;">
        <div class="btn-group" style="">
            <a id="btn_ok" class="btn btn-primary center-block btn-1" onclick="btn_ok()"><span class="glyphicon glyphicon-ok"></span> 确定</a>
        </div>
        <div class="btn-group" style="margin-left:30px;">
            <a id="btn_cancel" class="btn btn-danger center-block btn-1" onclick="btn_cancel()"><span class="glyphicon glyphicon-remove"></span> 关闭</a>
        </div>
    </div>
</div>